#include <iostream>
#include <string>
#include <memory>
#include <jsoncpp/json/json.h>

using namespace std;

int main()
{
  // deserialize 
  string str = R"({"name":"xiaohei" , "age":19 , "score":[58.5 , 66 , 35,5]})";
  Json::Value root; // instantiate a value objict 
  Json::CharReaderBuilder crb;  // subclass
  std::unique_ptr<Json::CharReader> cr(crb.newCharReader()); 
  string err;
  bool set = cr->parse(str.c_str() , str.c_str()+str.size() , &root , &err);

  if (set == false)
  {
    std::cerr << "json parse error!" << std::endl; 
  }

  std::cout << root["name"].asString() << std::endl;
  std::cout << root["age"].asString() << std::endl;
  int sz = root["score"].size();
  for(int i = 0; i < sz ; i++)
  {
    std::cout << root["score"][i] << std::endl;
  }
  return 0;
}
